package com.service.quartz.controller;

import com.service.quartz.dto.JobDto;
import com.service.quartz.dto.TaskDto;
import com.service.quartz.service.JobService;
import com.tool.base.base.BaseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/job")
public class JobController {
    @Autowired
    private JobService jobService;

    @PostMapping
    public BaseDto<TaskDto> createJob(@RequestBody JobDto jobDto) {
        return new BaseDto<>(jobService.createJob(jobDto));
    }

    @DeleteMapping("{id}")
    public BaseDto removeJob(@PathVariable(name = "id") int id) {
        jobService.removeJob(id);
        return new BaseDto<>();
    }

    @GetMapping("{id}")
    public BaseDto<TaskDto> getJob(@PathVariable(name = "id") int id) {
        return new BaseDto<>(jobService.getJob(id));
    }
}
